import openpyxl
import xlwt

from keys import Key


def data_new(value):
    data = {}
    if value is not None:
        str_temp = value.split(';')
        for temp in str_temp:
            temp = temp.split('=', 1)
            data[temp[0]] = temp[1]
    else:
        data = None
    return data


excel = openpyxl.load_workbook('demo.xlsx')
for name in excel.sheetnames:
    sheet = excel[name]
    for values in sheet.values:
        if type(values[0]) is int:
            data = data_new(values[2])
            if values[1] == 'open_browser':
                key = Key(**data)
            elif "assert" in values[1]:
                pass
            else:
                if data is not None:
                    getattr(key, values[1])(**data)
                else:
                    getattr(key, values[1])()
